package neves.android.etmg;

import neves.android.etmg.map.GameMap;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.TextView;


public class ETMG extends Activity {
    /** Called when the activity is first created. */
	
    /** A handle to the thread that's actually running the animation. */
    private GameCore gameThread;

    /** A handle to the View in which the game is running. */
    private ETMGView mainView;
	
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // turn off the window's title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        // tell system to use the layout defined in our XML file
        setContentView(R.layout.main);
        
        // get handles to the LunarView from XML, and its Thread
        mainView = (ETMGView) findViewById(R.id.etmg);
        
        gameThread = mainView.getThread();
        
        
        
        // give the View a handle to the TextView used for messages
        mainView.setTextView((TextView) findViewById(R.id.text));
        
        if (savedInstanceState == null) {
            // we were just launched: set up a new game
        	gameThread.setState(GameCore.STATE_READY);
            Log.w(this.getClass().getName(), "SIS is null");
        } else {
            // we are being restored: resume a previous game
        	gameThread.restoreState(savedInstanceState);
            Log.w(this.getClass().getName(), "SIS is nonnull");
        }
 
    }
    /**
     * Invoked when the Activity loses user focus.
     */
    @Override
    protected void onPause() {
        super.onPause();
        mainView.getThread().pause(); // pause game when Activity pauses
    }

    /**
     * Notification that something is about to happen, to give the Activity a
     * chance to save state.
     * 
     * @param outState a Bundle into which this Activity should save its state
     */
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        // just have the View's thread save its state into our Bundle
        super.onSaveInstanceState(outState);
        gameThread.saveState(outState);
        Log.w(this.getClass().getName(), "SIS called");
    }
    
	public void ShowNextFloorDialog(){
		new AlertDialog.Builder(this)
        .setTitle(R.string.str_StairDialogTitle)
        .setMessage(R.string.str_ToNextLevel)
		.setPositiveButton("Yes",
                                new DialogInterface.OnClickListener(){
                                        public void onClick(
                                                        DialogInterface dialoginterface, int i){
                                        
                                        }
                                })
        .show();
		
	}
    
}